import request from '@/utils/request'

/**
 * 获取文章
 * @param {*} channelID 频道的ID
 * @param {*} timestamp  请求第一页数据传当前的时间戳，请求上一页传上一页的时间戳
 * @returns Promise
 */
export const getArticleAPI = (channelID, timestamp) => {
  return request({
    url: '/v1_0/articles',
    params: {
      channel_id: channelID,
      timestamp: timestamp
    }
  })
}
/**
 * 获取新闻详情
 * @param {*} id 文章的ID
 * @returns
 */
export const getDetailAPI = (id) => {
  return request({
    url: `/v1_0/articles/${id}`
  })
}

/**
 * 文章点赞
 * @param {*} data
 * @returns
 */
export const getLikingsAPI = (data) => {
  return request({
    url: '/v1_0/article/likings',
    method: 'POST',
    data
  })
}

/**
 * 取消文章点赞
 * @param {*} target
 * @returns
 */
export const DelectlikingsAPI = (target) => {
  return request({
    url: `/v1_0/article/likings/${target}`,
    method: 'DELETE'
  })
}

/**
 * 收藏文章
 * @param {*} data
 * @returns
 */
export const getCollectionsAPI = (data) => {
  return request({
    url: '/v1_0/article/collections',
    method: 'POST',
    data
  })
}

/**
 *取消收藏文章
 * @param {*} target
 * @returns
 */
export const DelectcollectionsAPI = (target) => {
  return request({
    url: `/v1_0/article/collections/${target}`,
    method: 'DELETE'
  })
}
